import datetime

import ddt
import time
import unittest

from Base.BaseSetting import  TestData_dir
from Business.TeachingManagement_cx import WoniuInterface

@ddt.ddt
class TestWoniu(unittest.TestCase):
    start_time = time.strftime('%Y-%m-%d+%H', time.localtime(time.time()))
    end_time = (datetime.datetime.now() + datetime.timedelta(hours=2)).strftime("%Y-%m-%d+%H")

    start_time1 = time.strftime('%Y-%m-%d', time.localtime(time.time()))
    end_time1 = (datetime.datetime.now() + datetime.timedelta(days=7)).strftime("%Y-%m-%d")

    @classmethod
    def setUpClass(cls) -> None:
        cls.interface = WoniuInterface()


    @ddt.file_data(TestData_dir+'addApply.json')
    def test_addApply(self,**kwargs):
            """新增加班申请"""
            author = '陈雪'
            module = '教学管理'
            res,status_code = self.interface.addApply(kwargs.get('work_id'),kwargs.get('start_time'),kwargs.get('end_time'),kwargs.get('accounting_way'),kwargs.get('hours'))
            self.assertEqual(kwargs.get('expect'),res)

    @ddt.file_data(TestData_dir+'queryApply.json')
    def test_queryApply(self,**kwargs):
        """查询值班申请信息"""
        author = '陈雪'
        module = '教学管理'
        regionList,statusList,status_code = self.interface.queryApply(kwargs.get('pageSize'),kwargs.get('pageIndex'),kwargs.get('status'),kwargs.get('regionId'),kwargs.get('start_time'),kwargs.get('end_time'))
        # for region in regionList:
        #     if region != "":
        #         self.assertEqual('成都',region)
        for status in statusList:
            if status != "":
                self.assertEqual(kwargs.get('expect'),status)

    @ddt.file_data(TestData_dir+'assignWork.json')
    def test_assignWork(self,**kwargs):
        """指定值班"""
        author = '陈雪'
        module = '教学管理'
        res,status_code = self.interface.assignWork(kwargs.get('work_id'),kwargs.get('date'))
        self.assertEqual(kwargs.get('expect'),res)

    @ddt.file_data(TestData_dir+'queryDuty.json')
    def test_queryDuty(self,**kwargs):
        """根据编号查询值班信息"""
        author = '陈雪'
        module = '教学管理'
        id,status_code = self.interface.queryDuty(kwargs.get('pageSize'),kwargs.get('pageIndex'),kwargs.get('code'))
        # print(type(id))
        self.assertEqual(kwargs.get('expect'),id)

    def test_editDuty(self):
        """编辑值班信息"""
        author = '陈雪'
        module = '教学管理'
        res,status_code = self.interface.editDuty()
        self.assertEqual('success',res)


if __name__ == '__main__':
    unittest.main()